<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="UTF-8"/>
<meta http-equiv="Cache-Control" content="no-transform"/>
<meta http-equiv="Cache-Control" content="no-siteapp"/>
<meta name="applicable-device" content="mobile"/>
<meta name="renderer" content="webkit"/>
<meta name="format-detection" content="telephone=no"/>
<meta content="email=no" name="format-detection"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<?php 
$boke8 = get_option('leonhere');
if($boke8['seo'] == 'start'){	
if(!empty($boke8['separator'])){
	$separator = $boke8['separator'];
}else{
	$separator = '_';
}
if(is_home()){
	if(!empty($boke8['title'])){
		$title = $boke8['title'];
	}else{
		$title = get_bloginfo('name').$separator.get_bloginfo('description');
	}
	if(!empty($boke8['keywords'])){
		$keywords = $boke8['keywords'];
	}else{
		$keywords = get_bloginfo('name');
	}
	if(!empty($boke8['description'])){
		$description = $boke8['description'];
	}else{
		$description = get_bloginfo('description');
	}
}elseif(is_category()){
	if(get_term_meta($cat ,'title',true)){
		$title = get_term_meta($cat ,'title',true);
	}else{
		$title = single_cat_title('',false).$separator.get_bloginfo('name');
	}
	if(get_term_meta($cat ,'key',true)){
		$keywords = get_term_meta($cat ,'key',true);
	}else{
		$keywords = single_cat_title('',false);
	}
	if(get_term_meta($cat ,'des',true)){
		$description = get_term_meta($cat ,'des',true);
	}else{
		$description = strip_tags(category_description());
		$description = str_replace("\n","",$description);
	}
}elseif(is_tag()){
	$tag_name = single_tag_title('',false);
	$tagObject = get_term_by('name',$tag_name,'post_tag');
	$tagid = $tagObject->term_id;
	if(get_term_meta($tagid ,'title',true)){
		$title = get_term_meta($tagid ,'title',true);
	}else{
		$title = single_cat_title('',false).$separator.get_bloginfo('name');
	}
	if(get_term_meta($tagid ,'key',true)){
		$keywords = get_term_meta($tagid ,'key',true);
	}else{
		$keywords = single_cat_title('',false);
	}
	if(get_term_meta($tagid ,'des',true)){
		$description = get_term_meta($tagid ,'des',true);
	}else{
		$description = strip_tags(tag_description());
		$description = str_replace("\n","",$description);
	}
}elseif(is_tax()){
	$term = get_term_by('slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
	$termid = $term->term_id;
	if(get_term_meta($termid ,'title',true)){
		$title = get_term_meta($termid ,'title',true);
	}else{
		$title = single_cat_title('',false).$separator.get_bloginfo('name');
	}
	if(get_term_meta($termid ,'key',true)){
		$keywords = get_term_meta($termid ,'key',true);
	}else{
		$keywords = single_cat_title('',false);
	}
	if(get_term_meta($termid ,'des',true)){
		$description = get_term_meta($termid ,'des',true);
	}else{
		$description = strip_tags(term_description($termid));
		$description = str_replace("\n","",$description);
	}
}elseif(is_single()){
	if(get_post_meta($post->ID, "title", true)){
		$title = get_post_meta($post->ID, "title", true).$separator.get_bloginfo('name');
	}else{
		$title = single_post_title('',false).$separator.get_bloginfo('name');
	}
	if(get_post_meta($post->ID, "keywords", true)){
		$keywords = get_post_meta($post->ID, "keywords", true);
	}else{
		$keywords = tagtext();
	}
	if(get_post_meta($post->ID, "description", true)){
		$description = get_post_meta($post->ID, "description", true);
	}else{
		$description = wp_trim_words($post->post_content, 110, '...');
		$description = str_replace("\n","",$description);
	}
}elseif(is_page()){
	if(get_post_meta($post->ID, "title", true)){
		$title = get_post_meta($post->ID, "title", true).$separator.get_bloginfo('name');
	}else{
		$title = single_post_title('',false).$separator.get_bloginfo('name');
	}
	if(get_post_meta($post->ID, "keywords", true)){
		$keywords = get_post_meta($post->ID, "keywords", true);
	}else{
		$keywords = single_post_title('',false);
	}
	if(get_post_meta($post->ID, "description", true)){
		$description = get_post_meta($post->ID, "description", true);
	}else{
		$description = wp_trim_words($post->post_content, 110, '...');
		$description = str_replace("\n","",$description);
	}
}elseif(is_search()){
	$title = '关键词 '.wp_specialchars($s).' 的全站搜索结果';
	$keywords = wp_specialchars($s);
	$description = '';
}else{
	$title = wp_title('',false).$separator.get_bloginfo('name');
	if(!empty($boke8['keywords'])){
		$keywords = $boke8['keywords'];
	}else{
		$keywords = get_bloginfo('name');
	}
	if(!empty($boke8['description'])){
		$description = $boke8['description'];
	}else{
		$description = get_bloginfo('description');
	}
}
?>
<title><?php if($paged > 1){echo '第'.$paged.'页'.$separator;}?><?php echo $title; ?></title>
<meta name="keywords" content="<?php echo $keywords; ?>"/>
<meta name="description" content="<?php echo $description;?>"/>
<?php }else{?>
<title><?php if (is_home()){bloginfo('name'); echo '_'; bloginfo('description');}else{ wp_title('',true); echo '_'; bloginfo('name'); } ?></title>
<?php } ?>
<link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); ?>" media="screen" />
<script src="<?php bloginfo('template_url');?>/js/jquery-3.3.1.min.js"></script>
<!--[if lt IE 9]>
<script type="text/javascript" src="<?php bloginfo('template_url');?>/js/html5shiv.v3.72.min.js"></script>
<![endif]-->
<script src="<?php bloginfo('template_url');?>/js/fastclick.js"></script>
<?php if(is_singular()){?>
<script src="<?php bloginfo('template_url');?>/js/qrcode.min.js"></script>
<?php } ?>
<?php if(is_singular()) wp_enqueue_script('comment-reply');?>
<?php wp_head();?>
</head>
<body <?php body_class(); ?>>
<header class="header">
	<div class="inner">
		<?php if(is_single() || is_page()){?>
		<div class="logo">
			<a title="<?php bloginfo('name'); ?>" href="<?php bloginfo('url'); ?>"<?php if(!empty($boke8['logo'])){?> style="background-image:url(<?php echo $boke8['logo'];?>);"<?php } ?>><?php bloginfo('name'); ?></a>
		</div>
		<?php }else{ ?>
		<h1 class="logo">
			<a title="<?php bloginfo('name'); ?>" href="<?php bloginfo('url'); ?>"<?php if(!empty($boke8['logo'])){?> style="background-image:url(<?php echo $boke8['logo'];?>);"<?php } ?>><?php bloginfo('name'); ?></a>
		</h1>
		<?php } ?>
		<div class="wapbtn">
			<div class="searchbtn"></div>
			<div class="navbtn"></div>
		</div>
		<div class="right">
			<div class="topsearch">
				<form method="get" id="topsearch" action="<?php bloginfo('url');?>/">
					<div class="input">
						<input type="text" name="s" class="text" value="" placeholder="微信" />
					</div>
					<input type="submit" name="submit" class="submit" value="搜索"/>
				</form>
			</div>
			<div class="searchtags">
				关键词：<?php wp_tag_cloud('unit=px&smallest=14&largest=14&number=6&order=DESC'); ?>
			</div>
		</div>
	</div>
</header>
<div class="bar">
	<div class="inner">		
		<?php 
			if(function_exists('wp_nav_menu')){
				wp_nav_menu( array('theme_location' =>'header-menu','container' => 'nav','container_class' => 'nav','menu_class' => 'nav','depth' => 0,'items_wrap' => '<ul class="menus">%3$s</ul>'));
			}
		?>
		<div class="social">
			<ul>
				<?php if(!empty($boke8['weixin'])){?>
				<li class="wx">
					<a href="javascript:void(0);"><i></i>微信</a>
					<div class="qr">
						<img src="<?php echo $boke8['weixin'];?>" alt="微信"/>
					</div>
				</li>
				<?php } ?>
				<?php if(!empty($boke8['weibo'])){?>
				<li class="wb">
					<a rel="nofollow" href="<?php echo $boke8['weibo'];?>" target="_blank" title="微博"><i></i>微博</a>					
				</li>
				<?php } ?>
			</ul>
		</div>
		<div class="clear"></div>
	</div>
</div>
<?php if(!empty($boke8['topad'])){?>
<div class="hmdiv">
	<div class="inner">
	<?php echo htmlspecialchars_decode($boke8['topad']);?>
	</div>
</div>
<?php } ?>